package com.the4man.framework.util;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;

/**
 * Created by lenovo on 2017/12/12.
 */
public class SpringContextUtil {
    private static WebApplicationContext springContext;

    public SpringContextUtil() {
    }

    private static WebApplicationContext getSpringContextInstant() {
        return springContext;
    }

    public static void initSpringContext(ServletContext servletContext) {
        springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    }

    public static Object getBean(String name) {
        return getSpringContextInstant().getBean(name);
    }
}
